package com.sfx.shortLink.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sfx.shortLink.dao.entity.LinkStatsTodayDO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;

public interface ILinkStatsTodayMapper extends BaseMapper<LinkStatsTodayDO> {

    // 唯一索引 : full_short_url, gid, date
    @Insert("INSERT INTO t_link_stats_today(gid, full_short_url, date, today_pv, today_uv, today_uip, create_time, update_time, del_flag)" +
            "VALUES( #{linkStatsToday.gid}, #{linkStatsToday.fullShortUrl}, #{linkStatsToday.date}, #{linkStatsToday.todayPv},#{linkStatsToday.todayUv}," +
            "#{linkStatsToday.todayUip}, NOW(), NOW(), 0) ON DUPLICATE KEY UPDATE " +
            "today_pv = today_pv +  #{linkStatsToday.todayPv}, " +
            "today_uv = today_uv + #{linkStatsToday.todayUv}, " +
            "today_uip = today_uip + #{linkStatsToday.todayUip};")
    void totayStats(@Param("linkStatsToday") LinkStatsTodayDO linkStatsToday);
}
